1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module sourceview.HoverContext; 26 27 private import glib.MemorySlice; 28 private import gobject.ObjectG; 29 private import gtk.TextIter; 30 private import sourceview.Buffer; 31 private import sourceview.View; 32 private import sourceview.c.functions; 33 public import sourceview.c.types; 34 35 36 /** 37 * Context for populating [class@HoverDisplay] contents. 38 * 39 * `GtkSourceHoverContext` contains information about the request to populate 40 * contents for a [class@HoverDisplay]. 41 * 42 * It can be used to retrieve the [class@View], [class@Buffer], and 43 * [struct@Gtk.TextIter] for the regions of text which are being displayed. 44 * 45 * Use [method@HoverContext.get_bounds] to get the word that was 46 * requested. [method@HoverContext.get_iter] will get you the location 47 * of the pointer when the request was made. 48 */ 49 public class HoverContext : ObjectG 50 { 51 /** the main Gtk struct */ 52 protected GtkSourceHoverContext* gtkSourceHoverContext; 53 54 /** Get the main Gtk struct */ 55 public GtkSourceHoverContext* getHoverContextStruct(bool transferOwnership = false) 56 { 57 if (transferOwnership) 58 ownedRef = false; 59 return gtkSourceHoverContext; 60 } 61 62 /** the main Gtk struct as a void* */ 63 protected override void* getStruct() 64 { 65 return cast(void*)gtkSourceHoverContext; 66 } 67 68 /** 69 * Sets our main struct and passes it to the parent class. 70 */ 71 public this (GtkSourceHoverContext* gtkSourceHoverContext, bool ownedRef = false) 72 { 73 this.gtkSourceHoverContext = gtkSourceHoverContext; 74 super(cast(GObject*)gtkSourceHoverContext, ownedRef); 75 } 76 77 78 /** */ 79 public static GType getType() 80 { 81 return gtk_source_hover_context_get_type(); 82 } 83 84 /** 85 * Gets the current word bounds of the hover. 86 * 87 * If @begin is non-%NULL, it will be set to the start position of the 88 * current word being hovered. 89 * 90 * If @end is non-%NULL, it will be set to the end position for the 91 * current word being hovered. 92 * 93 * Params: 94 * begin = a #GtkTextIter 95 * end = a #GtkTextIter 96 * 97 * Returns: %TRUE if the marks are still valid and @begin or @end was set. 98 */ 99 public bool getBounds(out TextIter begin, out TextIter end) 100 { 101 GtkTextIter* outbegin = sliceNew!GtkTextIter(); 102 GtkTextIter* outend = sliceNew!GtkTextIter(); 103 104 auto __p = gtk_source_hover_context_get_bounds(gtkSourceHoverContext, outbegin, outend) != 0; 105 106 begin = ObjectG.getDObject!(TextIter)(outbegin, true); 107 end = ObjectG.getDObject!(TextIter)(outend, true); 108 109 return __p; 110 } 111 112 /** 113 * A convenience function to get the buffer. 114 * 115 * Returns: The #GtkSourceBuffer for the view 116 */ 117 public Buffer getBuffer() 118 { 119 auto __p = gtk_source_hover_context_get_buffer(gtkSourceHoverContext); 120 121 if(__p is null) 122 { 123 return null; 124 } 125 126 return ObjectG.getDObject!(Buffer)(cast(GtkSourceBuffer*) __p); 127 } 128 129 /** */ 130 public bool getIter(TextIter iter) 131 { 132 return gtk_source_hover_context_get_iter(gtkSourceHoverContext, (iter is null) ? null : iter.getTextIterStruct()) != 0; 133 } 134 135 /** 136 * Returns: the #GtkSourceView that owns the context 137 */ 138 public View getView() 139 { 140 auto __p = gtk_source_hover_context_get_view(gtkSourceHoverContext); 141 142 if(__p is null) 143 { 144 return null; 145 } 146 147 return ObjectG.getDObject!(View)(cast(GtkSourceView*) __p); 148 } 149 }